package 笔试.A阿里巴巴;

import java.util.HashSet;
import java.util.Scanner;

public class second {
    public static void main(String arg[]){//main--来自高金磊

         Scanner scanner=new Scanner(System.in);
         int n=scanner.nextInt();
         int m=scanner.nextInt();

        int data[][]=new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                int input=scanner.nextInt();
                if (input==0)
                    data[i][j]=2;
                else data[i][j]=1;
            }
        }
        for (int i = 0; i < n; i++) {
            int target=0;
            for (int j = 0; j < m; j++) {
                if (target==0){
                    if (data[i][j]==1)
                        target=1;
                    continue;
                }
                if (data[i][j]>1){
                    data[i][j]+=1;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            int target=0;
            for (int j = m-1; j >=0; j--) {
                if (target==0){
                    if (data[i][j]==1)
                        target=1;
                    continue;
                }
                if (data[i][j]>1){
                    data[i][j]+=1;
                }
            }
        }


        for (int j = 0; j < m; j++) {
            int target=0;
            for (int i = 0; i < n; i++) {
                if (target==0){
                    if (data[i][j]==1)
                        target=1;
                    continue;
                }
                if (data[i][j]>1){
                    data[i][j]+=1;
                }
            }
        }
        for (int j = 0; j < m; j++) {
            int target=0;
            for (int i = n-1; i >=0; i--) {
                if (target==0){
                    if (data[i][j]==1)
                        target=1;
                    continue;
                }
                if (data[i][j]>1){
                    data[i][j]+=1;
                }
            }
        }

        int res=0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(data[i][j]>2){
                    res+=data[i][j]-2;
                }
            }
        }
        System.out.println(res);

    }


}
